clear all

// SET MACROS
global Input  "Y:/limited/Michigan_CTE/funding_change/data_derived/imported"
global Output "Y:/limited/Michigan_CTE/funding_change/data_derived"

// LOAD DATA
use $Input/census_block.dta

// RENAME VARIABLES
rename fips2010 censusblockgroup

// Keep 2011-2015 ACS
keep if year==2013
drop year

// CLEAN VARIABLES

// BA or above
gen cbg_baplus     = edu_ba + edu_pro + edu_ms
gen cbg_baplus_imp = missing(cbg_baplus)
replace cbg_baplus = 1 if cbg_baplus_imp==1

// KEEP VARIABLES
keep  censusblockgroup cbg_baplus cbg_baplus_imp

// ORDER VARIBLES
order censusblockgroup  cbg_baplus cbg_baplus_imp

// FORMAT VARIABLES
format cbg_baplus %6.2f

// VARIABLE LABELS
label var censusblockgroup "Census block group"
label var cbg_baplus "Bachelor's degree or higher"
label var cbg_baplus_imp "Imputed Bachelor's degree or higher"

// SORT & SAVE
sort censusblockgroup
compress
save $Output/census_block.dta, replace
